import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import ACCESS_ENUM from "@/utils/access/ACCESS_ENUM.ts";
import NoAuth from "@/NoAuth.vue";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'image',
      component: HomeView,
    },
    {
      path: '/product/:id',
      name: 'product-detail',
      component: () => import('@/views/ProductDetailView.vue'),
      props: true,
    },
    {
      path: '/shop/:id',
      name: 'shop',
      component: () => import('../views/ShopView.vue'),
    },
    {
      path: '/cart',
      name: 'cart',
      component: () => import('../views/CartView.vue'),
    },
    {
      path: '/orders',
      name: 'orders',
      component: () => import('../views/OrderView.vue'),
    },
    {
      path: '/profile',
      name: 'profile',
      component: () => import('../views/ProfileView.vue'),
    },
    {
      path: '/admin',
      name: 'admin-dashboard',
      component: () => import('../views/AdminDashboardView.vue'),
    },
    {
      path: '/admin/statistics',
      name: 'admin-statistics',
      component: () => import('../views/AdminStatisticsView.vue'),
    },
    {
      path: '/admin/products',
      name: 'admin-products',
      component: () => import('../views/AdminProductManageView.vue'),
    },
    {
      path: '/admin/orders',
      name: 'admin-orders',
      component: () => import('../views/AdminOrderManageView.vue'),
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/user/LoginView.vue'),
    },
    {
      path: '/register',
      name: 'register',
      component: () => import('../views/user/RegisterView.vue'),
    },
    {
      path: '/checkout/:id',
      name: 'checkout',
      component: () => import('../views/CheckoutView.vue'),
      props:true
    },
    {
      path: '/noAuth',
      name: '无权限页面',
      component: NoAuth,
      meta:{
        access:ACCESS_ENUM.NOT_LOGIN,
      }
    },
  ],
})

export default router
